﻿using gbL.NetBoard.Examples.DoubleMVC;
using gbL.NetBoard.Examples.DoubleMVC.View.UI;
using gbL.NetBoard.Examples.DoubleMVC.View.UI.Requests;
using NUnit.Framework;
using Rhino.Mocks;

namespace gbL.NetBoard.Examples.DoubleMVC.Tests
{
    [TestFixture]
    public class MenuViewTests
    {
        [Test]
        public void Should_display_a_populated_MenuViewRequest()
        {
            Blackboard domain = new Blackboard();
            IOutputTarget outputMock = MockRepository.GenerateMock<IOutputTarget>();
            MenuView view = new MenuView(domain, outputMock);
            MenuViewRequest request = new MenuViewRequest();
            request.MenuTitle = "Menu title";
            request.Content = "Menu content";
            // A
            domain.Add(request);
            // A
            outputMock.AssertWasCalled(x => x.Clear());
            outputMock.AssertWasCalled(x => x.WriteLine("Menu title"));
            outputMock.AssertWasCalled(x => x.WriteLine("----------"));
            outputMock.AssertWasCalled(x => x.WriteLine("Menu content"));
        }

        [Test]
        public void Should_remove_displayed_request_from_board()
        {
            Blackboard domain = new Blackboard();
            MenuView view = new MenuView(domain, MockRepository.GenerateStub<IOutputTarget>());
            MenuViewRequest request = new MenuViewRequest();
            request.MenuTitle = "Menu title";
            request.Content = "Menu content";
            // A
            domain.Add(request);
            // A
            Assert.That(
                domain.Read(e => true),
                Has.Count.EqualTo(0)
            );
        }
    }
}
